package com.iepacj.pattern.observer;

/**
 * Created by iEpac on 16/6/12.
 */
public class CurrentConditionDisplay implements DisplayElement, Observer {

    private float temp;

    private float humidity;

    private float pressure;

    private Subject weatherData;

    public CurrentConditionDisplay(Subject weather) {
        this.weatherData = weather;
        weatherData.registerObserver(this);
    }

    @Override
    public void display() {
        System.out.println("Current Conditions " + temp + "F degrees and " + humidity + "% humidity");
    }

    @Override
    public void update(float temp, float humidity, float pressure) {
        this.temp = temp;
        this.humidity = humidity;
        this.pressure = pressure;
        display();
    }
}
